<template>
  <div>
    <el-card style="margin-top: 5px">
      <el-form ref="form" :model="formData" label-width="80px">
        <el-row>
          <el-col :span="18">
            <el-form-item label="监督机构" prop="orgId" style="margin-left: 50px;margin-top: 20px">
              <el-select v-model="formData.orgId" clearable style="margin-left: 20px;" placeholder="请选择">
                <el-option
                  v-for="item in orglist"
                  :key="item.id"
                  :label="item.orgName"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" style="margin-top: 20px">
            <el-col :span="3">
              <el-button type="success" @click="quire" icon="el-icon-search">检索</el-button>
            </el-col>
            <el-col :span="3" style="margin-left: 80px">
              <download-excel
                class="export-excel-wrapper"
                :data="personlist"
                :fields="fields"
                :header="title"
                name="人员构成情况表.xls">
                <el-button type="warning" icon="el-icon-download" >导出</el-button>
              </download-excel>
            </el-col>
          </el-col>
        </el-row>
      </el-form>
      <el-table
        :data="personlist"
        border style="width:100%; font-size: 5px">
        <el-table-column
          prop="orgname"
          label="监督机构"
          width="160">
        </el-table-column>
        <el-table-column  label="年龄" prop="nian" width="20">
          <el-table-column label="25岁以下" width="35" prop="a">
          </el-table-column>
          <el-table-column label="26到30岁" width="35" prop="b">
          </el-table-column>
          <el-table-column label="31岁到35岁" width="50" prop="c">
          </el-table-column>
          <el-table-column label="36岁到40岁" width="50" prop="d">
          </el-table-column>
          <el-table-column label="41岁到45岁" width="50" prop="e">
          </el-table-column>
          <el-table-column label="46岁到50岁" width="50" prop="f">
          </el-table-column>
          <el-table-column label="51岁到54岁" width="50" prop="g">
          </el-table-column>
          <el-table-column label="55岁及以上" width="50" prop="h">
          </el-table-column>
        </el-table-column>
        <el-table-column label="性别">
          <el-table-column label="男" prop="men"  width="35">
          </el-table-column>
          <el-table-column label="女" prop="women" width="35">
          </el-table-column>
        </el-table-column>
        <el-table-column  label="学历" width="20">
          <el-table-column label="博士" prop="doctor" width="35">
          </el-table-column>
          <el-table-column label="研究生" prop="Master" width="35">
          </el-table-column>
          <el-table-column label="大学本科" prop="undergraduate " width="35">
          </el-table-column>
          <el-table-column label="大学专科" prop="college" width="35">
          </el-table-column>
          <el-table-column label="中专" prop="special " width="35">
          </el-table-column>
          <el-table-column label="高中及以下" prop="st" width="50">
          </el-table-column>
        </el-table-column>
        <el-table-column  label="职级"  >
          <el-table-column label="省部级正职" prop="rb" width="50">
          </el-table-column>
          <el-table-column label="省部级副职" prop="rc" width="50">
          </el-table-column>
          <el-table-column label="厅局级正职" prop="rd" width="50">
          </el-table-column>
          <el-table-column label="厅局级副职" prop="re" width="50">
          </el-table-column>
          <el-table-column label="县处级正职" prop="rf" width="50">
          </el-table-column>
          <el-table-column label="县处级副职" prop="rg" width="50">
          </el-table-column>
          <el-table-column label="乡科级正职" prop="rh" width="50">
          </el-table-column>
          <el-table-column label="乡科级副职" prop="ri" width="50">
          </el-table-column>
          <el-table-column label="科办员" prop="rj" width="35">
          </el-table-column>
          <el-table-column label="无职级" prop="ra" width="35">
          </el-table-column>
          <el-table-column label="合计" prop="totalrank" width="35">
          </el-table-column>
        </el-table-column>
        <el-table-column  label="专业技术职称" width="20">
          <el-table-column label="正高级" prop="td" width="35">
          </el-table-column>
          <el-table-column label="副高级" prop="tc" width="35">
          </el-table-column>
          <el-table-column label="中级" prop="tb" width="35">
          </el-table-column>
          <el-table-column label="初级" prop="ta" width="35">
          </el-table-column>
          <el-table-column label="未聘请专业技术职称" prop="te" width="50">
          </el-table-column>
          <el-table-column label="合计" prop="totaltitle" width="35">
          </el-table-column>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
  import {post} from "@/utils/api";
  export default {
    data() {
      return {
        formData:{},
        orglist:[],
        personlist:[],
        ids:[],
        title:"人员构成情况表",
        fields:{'监督机构':'orgname','25岁以下':'a','26到30岁':'b','31岁到35岁':'c','36岁到40岁':'d','41岁到45岁':'e','46岁到50岁':'f','51岁到54岁':'g','55岁及以上':'h','男':'men','女':'women',
        '博士':'doctor','研究生':'Master','大学本科':'undergraduate','大学专科':'college','中专':'special','高中及以下':'st','省部级正职':'rb','省部级副职':'rc','厅局级正职':'rd','厅局级副职':'re',
        '县处级正职':'rf','县处级副职':'rg','乡科级正职':'rh','乡科级副职':'ri','科办员':'rj','无职级':'ra','合计':'totalrank','正高级':'td','副高级':'tc','中级':'tb','初级':'ta','未聘请专业技术职称':'te','专业技术职称合计':'totaltitle'}
      }
    },
    async created() {
      let res = await post("org/getallorg")
      this.orglist = res
      let res1 = await post("person/getallorgid")
      this.ids = res1.map((item,index)=>{
        return item.orgId
      })
      console.log(this.ids)
      this.getbypage()
      },
    methods: {
      async getbypage() {
        let res1 = await post("person/get1", {id: this.ids})
        let res2 = await post("person/get2", {id: this.ids})
        let res3 = await post("person/get3", {id: this.ids})
        let res4 = await post("person/get4", {id: this.ids})
        let res5 = await post("person/get5", {id: this.ids})
        this.personlist = res1.map((item,index)=>{
          return {...item,...res2[index],...res3[index],...res4[index],...res5[index]}
        })
        console.log(this.personlist);
      },
      async quire() {
        console.log(this.formData.orgId)
        // this.ids=[]
        // this.ids = this.formData.orgId
        if(this.formData.orgId == undefined){
          this.getbypage()
        }else{
          let res1 = await post("person/get1", {id: this.formData.orgId})
          let res2 = await post("person/get2", {id: this.formData.orgId})
          let res3 = await post("person/get3", {id: this.formData.orgId})
          let res4 = await post("person/get4", {id: this.formData.orgId})
          let res5 = await post("person/get5", {id: this.formData.orgId})
          this.personlist = res1.map((item, index) => {
            return {...item, ...res2[index], ...res3[index], ...res4[index], ...res5[index]}
          })
        }

      },

    }
  }
</script>
<style></style>
